package com.tql.pandian.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.tql.pandian.entity.sys.dto.SysMenuDTO;
import com.tql.pandian.entity.sys.dto.SysRoleDTO;
import com.tql.pandian.entity.sys.dto.SysSelectUserDTO;
import com.tql.pandian.entity.sys.dto.SysUserDTO;
import com.tql.pandian.service.IH5RoleMenuService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@ApiOperation("H5角色菜单")
@RestController
@RequestMapping("/H5RoleMenu")
public class H5RoleMenuController extends BaseController {

    @Autowired
    private IH5RoleMenuService ih5RoleMenuService;

    @ApiOperation("添加菜单")
    @PostMapping("/addMenu")
    public AjaxResult addMenu(@RequestBody SysMenuDTO sysMenuDTO){
        return success(ih5RoleMenuService.addMenu(sysMenuDTO));
    }

    @ApiOperation("获取菜单列表")
    @GetMapping("/getMenu")
    public AjaxResult getMenu(){
        return success(ih5RoleMenuService.getMenu());
    }

    @ApiOperation("添加角色")
    @PostMapping("/addRole")
    public AjaxResult addRole(@RequestBody SysRoleDTO sysRoleDTO){
        return success(ih5RoleMenuService.addRole(sysRoleDTO));
    }

    @ApiOperation("获取角色下拉")
    @GetMapping("/getRoleList")
    public AjaxResult getRoleList(){
        return success(ih5RoleMenuService.getRoleList());
    }


    @ApiOperation("根据角色ID获取角色信息")
    @PostMapping("/getRole/{roleId}")
    public AjaxResult getRole(@PathVariable Long roleId){
        return success(ih5RoleMenuService.getRole(roleId));
    }


    @ApiOperation("修改角色")
    @PostMapping("/updateRole")
    public AjaxResult updateRole(@RequestBody SysRoleDTO sysRoleDTO){
        return success(ih5RoleMenuService.updateRole(sysRoleDTO));
    }

    @ApiOperation("删除角色")
    @PostMapping("/deleteRole/{roleId}")
    public AjaxResult deleteRole(@PathVariable Long roleId){
        return success(ih5RoleMenuService.deleteRole(roleId));
    }


    @ApiOperation("APP账号列表")
    @GetMapping("/getAppUser")
    public AjaxResult getAppUser(){
        return success(ih5RoleMenuService.getAppUser());
    }

    @ApiOperation("添加登录账号")
    @PostMapping("/addAppUser")
    public AjaxResult addAppUser(@RequestBody SysUserDTO sysUserDTO){
        return success(ih5RoleMenuService.addAppUser(sysUserDTO));
    }

    @ApiOperation("通过用户Id获取用户信息")
    @GetMapping("/getAppUserByUserId/{userId}")
    public AjaxResult getAppUserByUserId(@PathVariable Long userId){
        return success(ih5RoleMenuService.getAppUserByUserId(userId));
    }

    @ApiOperation("修改登录账号绑定的角色1")
    @PostMapping("/editAppUser")
    public AjaxResult editAppUser(@RequestBody SysUserDTO sysUserDTO){
        return success(ih5RoleMenuService.editAppUser(sysUserDTO));
    }

    @ApiOperation("通过用户Id-删除用户")
    @GetMapping("/deleteAppUserByUserId/{userId}")
    public AjaxResult deleteAppUserByUserId(@PathVariable Long userId){
        return success(ih5RoleMenuService.deleteAppUserByUserId(userId));
    }

    @ApiOperation("选人")
    @PostMapping("/selectEmp/{idcard}")
    public AjaxResult selectUser(@PathVariable("idcard") String idcard){
        return success(ih5RoleMenuService.selectUser(idcard));
    }


    @ApiOperation("获取门店-树形结构")
    @GetMapping("/getStoreTree")
    public AjaxResult getStoreTree(){
        return success(ih5RoleMenuService.getStoreTree());
    }

}
